(function($) {
	$.fn.datetimepicker.dates['zh-CN'] = {
		days : [ "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日" ],
		daysShort : [ "周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日" ],
		daysMin : [ "日", "一", "二", "三", "四", "五", "六", "日" ],
		months : [ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月",
				"十一月", "十二月" ],
		monthsShort : [ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月",
				"十月", "十一月", "十二月" ],
		today : "今日",
		suffix : [],
		meridiem : [ "上午", "下午" ]
	};
	$('.form-datetime-lang').datetimepicker({
		language : 'zh-CN',
		format : 'yyyy-mm-dd hh:ii'
	});
	$('.form-datetime-langa').datetimepicker({
		language : 'zh-CN',
		format : 'yyyy-mm-dd hh:ii'
	});
}(jQuery));



$(function() {
	$('.chosen-select').chosen({
		max_selected_options : 50
	});
	$('.chosen-select').on('chosen:maxselected', function() {
		layer.msg('参与人不能超过50个', {
			icon : 5
		});
	});
});
function task() {
	var task = $("#taskusers").val();
	if (task == null) {
		layer.msg('你还没有选择出差人员！', {
			icon : 5
		});
	}

}



function shbfno(){
	layer.msg('没有数据无法备份！', {
		time : 1000,
		icon : 5
	});
}








function search() {
	var d = document.getElementById('getid').value;
	document.getElementById("tex").value = d;
	var search = document.getElementById('search').value;
	$.ajax({
		url : '/zxtms/index.php/Admin/Task/search',
		type : "GET",
		data : {
			"tex" : d,
			"search" : search
		},
		dataType : "json",
		beforeSend : function() {
			layer.msg('正在收搜....', {
				icon : 16,
				shade : 0.05
			});
		},
		success : function(data) {
			if (data.state == 1) {
				location.href = '/zxtms/index.php/Admin/Task/View?tex='
						+ data.id + '&&' + 'search=' + data.search;
			} else {
				layer.msg(data.msg, {
					icon : 5
				});
			}
		},
		error : function() {
			layer.msg('服务异常！');
		}
	});
}

function searchqj() {
	var d = document.getElementById('getid').value;
	document.getElementById("tex").value = d;
	var search = document.getElementById('search').value;
	$.ajax({
		url : '/zxtms/index.php/Admin/Leave/searchqj',
		type : "GET",
		data : {
			"tex" : d,
			"search" : search
		},
		dataType : "json",
		beforeSend : function() {
			layer.msg('正在收搜....', {
				icon : 16,
				shade : 0.05
			});
		},
		success : function(data) {
			if (data.state == 1) {
				location.href = '/zxtms/index.php/Admin/Leave/View?tex='
						+ data.id + '&&' + 'search=' + data.search;
			} else {
				layer.msg(data.msg, {
					icon : 5
				});
			}
		},
		error : function() {
			layer.msg('服务异常！');
		}
	});
}



function searchb() {
	var d = document.getElementById('getid').value;
	document.getElementById("tex").value = d;
	var search = document.getElementById('search').value;
	$.ajax({
		url : '/zxtms/index.php/Admin/Kqbf/searchb',
		type : "GET",
		data : {
			"tex" : d,
			"search" : search
		},
		dataType : "json",
		beforeSend : function() {
			layer.msg('正在收搜....', {
				icon : 16,
				shade : 0.05
			});
		},
		success : function(data) {
			if (data.state == 1) {
				location.href = '/zxtms/index.php/Admin/Kqbf/View?tex='
						+ data.id + '&&' + 'search=' + data.search;
			} else {
				layer.msg(data.msg, {
					icon : 5
				});
			}
		},
		error : function() {
			layer.msg('服务异常！');
		}
	});
}

/*document.getElementById('getid').value ='';*/
function select() {
	var d = document.getElementById('getid').value;
	document.getElementById("tex").value = d;
	$.ajax({
		url : "/zxtms/index.php/Admin/Task/montha",
		type : "GET",
		data : {
			"tex" : d
		},
		dataType : "json",
		cache : true,
		beforeSend : function() {
			layer.msg('正在加载数据....', {
				icon : 16,
				shade : 0.05
			});
		},
		success : function(data) {
			if (data.state == 1) {
				location.href = '/zxtms/index.php/Admin/Task/View?tex='
						+ data.d;
			} else {
				layer.msg(data.msg, {
					icon : 5
				});
			}
		},
		error : function() {
			layer.msg('服务异常！');
		}
	});
}

function selectqj() {
	var d = document.getElementById('getid').value;
	document.getElementById("tex").value = d;
	$.ajax({
		url : "/zxtms/index.php/Admin/Leave/qjmonth",
		type : "GET",
		data : {
			"tex" : d
		},
		dataType : "json",
		cache : true,
		beforeSend : function() {
			layer.msg('正在加载数据....', {
				icon : 16,
				shade : 0.05
			});
		},
		success : function(data) {
			if (data.state == 1) {
				location.href = '/zxtms/index.php/Admin/Leave/View?tex='
						+ data.d;
			} else {
				layer.msg(data.msg, {
					icon : 5
				});
			}
		},
		error : function() {
			layer.msg('服务异常！');
		}
	});
}


/*document.getElementById('getid').value = "";*/
function selecta() {
	var d = document.getElementById('getid').value;
	document.getElementById("tex").value = d;
	$.ajax({
		url : "/zxtms/index.php/Admin/Kqbf/monthb",
		type : "GET",
		data : {
			"tex" : d
		},
		dataType : "json",
		cache : true,
		beforeSend : function() {
			layer.msg('正在加载数据....', {
				icon : 16,
				shade : 0.05
			});
		},
		success : function(data) {
			if (data.state == 1) {
				location.href = '/zxtms/index.php/Admin/Kqbf/View?tex='
						+ data.d;
			} else {
				layer.msg(data.msg, {
					icon : 5
				});
			}
		},
		error : function() {
			layer.msg('服务异常！');
		}
	});
}



function del(id) {
	layer.confirm('您确定要删除这条数据吗？', {
		btn : [ '确定', '取消' ]
	}, function() {
		$.ajax({
			url : "/zxtms/index.php/Admin/Task/delete",
			type : "get",
			data : {
				"id" : id
			},
			dataType : "json",
			beforeSend : function() {
				layer.msg('正在删除', {
					icon : 16,
					shade : 0.01
				});
			},
			success : function(data) {
				if (data.state == 1) {
					location.href = location.href;
					layer.msg(data.msg, {
						icon : 6
					});
				} else {
					layer.msg(data.msg, {
						icon : 5
					});
				}
			},
			error : function() {
				layer.msg('服务异常！');
			}

		});

	});
}

function searchstaff() {
	var searchstaff = $('#searchstaff').val();
	$ajax({
		url : "/zxtms/index.php/Admin/Status",
		type : "get",
		data : {
			"searchstaff" : searchstaff
		},
		dataType : "json"
	});
}



function copya() {
	layer.msg('没有数据，无法批量操作', {
		time : 1000,
		icon : 5
	});
}

function push(){
	layer.confirm('您确定要导出该月份的所有数据吗？', {
		btn : [ '确定', '取消' ]
	}, function() {
		$.ajax({
			url : "/zxtms/index.php/Admin/Task/push",
			type : "post",			
			beforeSend : function() {
				layer.msg('正在导出....', {
					icon : 16,
					shade : 0.01
				});
			},			

		});

	});
}

function selectlate(){
	var d = document.getElementById('getid').value;
	document.getElementById("tex").value = d;
	$.ajax({
		url : "/zxtms/index.php/Admin/Late/lateb",
		type : "GET",
		data : {
			"tex" : d
		},
		dataType : "json",
		cache : true,
		beforeSend : function() {
			layer.msg('正在加载数据....', {
				icon : 16,
				shade : 0.05
			});
		},
		success : function(data) {
			if (data.state == 1) {
				location.href = '/zxtms/index.php/Admin/Late/View?tex='
						+ data.d;
			} else {
				layer.msg(data.msg, {
					icon : 5
				});
			}
		},
		error : function() {
			layer.msg('服务异常！');
		}
	});
}


function cdgl(){
	var selectall = document.getElementById('selectall');
	if (selectall.checked == false) {
		layer.msg('你还没有全选要删除的数据！', {
			icon : 5
		});
	} else {
		var cq = $(".cq");
		var plstr = "";
		for (var i = 0; i < cq.length; i++) {
			if (cq.eq(i).attr("checked")) {
				plstr += cq.eq(i).val() + ',';
			}
		}
		layer.confirm('您确定要删除该月份的所有数据吗？', {
			btn : [ '确定', '取消' ]
		}, function() {
			$.ajax({
				url : "/zxtms/index.php/Admin/Late/cdgl",
				type : "post",
				data : {
					'select' : plstr
				},
				dataType : "json",
				beforeSend : function() {
					layer.msg('正在批量删除....', {
						icon : 16,
						shade : 0.01
					});
				},
				success : function(data) {
					if (data.state == 1) {
						location.href = location.href;
						layer.msg(data.msg, {
							icon : 6
						});
					} else {
						layer.msg(data.msg, {
							icon : 5
						});
					}
				},
				error : function() {
					layer.msg('服务异常！');
				}

			});

		});

	}
}

function qjgl(){
	var selectall = document.getElementById('selectall');
	if (selectall.checked == false) {
		layer.msg('你还没有全选要删除的数据！', {
			icon : 5
		});
	} else {
		var cq = $(".cq");
		var plstr = "";
		for (var i = 0; i < cq.length; i++) {
			if (cq.eq(i).attr("checked")) {
				plstr += cq.eq(i).val() + ',';
			}
		}
		layer.confirm('您确定要删除该月份的所有数据吗？', {
			btn : [ '确定', '取消' ]
		}, function() {
			$.ajax({
				url : "/zxtms/index.php/Admin/Leave/qjgl",
				type : "post",
				data : {
					'select' : plstr
				},
				dataType : "json",
				beforeSend : function() {
					layer.msg('正在批量删除....', {
						icon : 16,
						shade : 0.01
					});
				},
				success : function(data) {
					if (data.state == 1) {
						location.href = location.href;
						layer.msg(data.msg, {
							icon : 6
						});
					} else {
						layer.msg(data.msg, {
							icon : 5
						});
					}
				},
				error : function() {
					layer.msg('服务异常！');
				}

			});

		});

	}
}





function copy() {
	var selectall = document.getElementById('selectall');
	if (selectall.checked == false) {
		layer.msg('你还没有全选要删除的数据！', {
			icon : 5
		});
	} else {
		var cq = $(".cq");
		var plstr = "";
		for (var i = 0; i < cq.length; i++) {
			if (cq.eq(i).attr("checked")) {
				plstr += cq.eq(i).val() + ',';
			}
		}
		layer.confirm('您确定要删除该月份的所有数据吗？', {
			btn : [ '确定', '取消' ]
		}, function() {
			$.ajax({
				url : "/zxtms/index.php/Admin/Task/copy",
				type : "post",
				data : {
					'select' : plstr
				},
				dataType : "json",
				beforeSend : function() {
					layer.msg('正在批量删除....', {
						icon : 16,
						shade : 0.01
					});
				},
				success : function(data) {
					if (data.state == 1) {
						location.href = location.href;
						layer.msg(data.msg, {
							icon : 6
						});
					} else {
						layer.msg(data.msg, {
							icon : 5
						});
					}
				},
				error : function() {
					layer.msg('服务异常！');
				}

			});

		});

	}

}

function lateee() {
	var latename = document.getElementById('latename').value;	
	var latemid = document.getElementById('latemid').value;
	var latetime = $('#latetime').val();
	if (latename == "" || latemid == "" || latetime == "") {
		layer.msg('这几项都不能为空！', {
			icon : 5
		});
	} else {

		$.ajax({
			url : "/zxtms/index.php/Admin/Late/insert",
			type : "post",
			data : {
				"latename" : latename,
				"latemid" : latemid,
				"latetime" : latetime				
			},
			dataType : "json",
			beforeSend : function() {
				layer.msg('正在提交....', {
					icon : 16,
					shade : 0.05
				});
			},
			success : function(data) {
				if (data.state == 1) {
					layer.msg(data.msg, {
						icon : 6
					});
					location.href = "/zxtms/index.php/Admin/Late/View";
				} else {
					layer.msg(data.msg, {
						icon : 5
					});
				}
			},
			error : function() {
				layer.msg('服务异常！');
			}
		});

	}

}

function total(id) {
	layer.confirm('您确定要计算该员工工资吗？', {
		btn : [ '确定', '取消' ]
	}, function() {
		$.ajax({
			url : "/zxtms/index.php/Admin/Kqbf/total",
			type : "get",
			data : {
				"id" : id
			},
			dataType : "json",
			beforeSend : function() {
				layer.msg('正在计算', {
					icon : 16,
					shade : 0.01
				});
			},
			success : function(data) {
				if (data.state == 1) {
					location.href = location.href;
					layer.msg(data.msg, {
						icon : 6
					});
				} else {
					layer.msg(data.msg, {
						icon : 5
					});
				}
			},
			error : function() {
				layer.msg('服务异常！');
			}

		});

	});
}

function shbf(){
	layer.confirm('您确定要导出所有数据吗？', {
		btn : [ '确定', '取消' ]
	}, function() {	
		location.href = location.href;
	$(".table2excel").table2excel({
		exclude: ".noExl",
		name: "Excel Document Name",
		filename: "zhixin",
		exclude_img: true,
		exclude_links: true,
		exclude_inputs: true
	});
	});

}



function leave() {
	
	var mid = $('#mid').val();
	var leaveuser = document.getElementById('leaveuser').value;
	var leavetime = $('#leavetime').val();
	var leavedate = $('#leavedate').val();
	var leaveinfo = $('#leaveinfo').val();

	if (leaveuser == "" || mid == "" || leavetime == "" || leavedate == ""
			|| leaveinfo == "") {
		layer.msg('这几项都不能为空！', {
			icon : 5
		});
	} else {

		$.ajax({
			url : "/zxtms/index.php/Admin/Leave/insert",
			type : "post",
			data : {
				"leaveuser" : leaveuser,
				" mid" :  mid,
				"leavetime" : leavetime,
				"leavedate" : leavedate,
				"leaveinfo" : leaveinfo
			},
			dataType : "json",
			beforeSend : function() {
				layer.msg('正在提交....', {
					icon : 16,
					shade : 0.05
				});
			},
			success : function(data) {
				if (data.state == 1) {
					layer.msg(data.msg, {
						icon : 6
					});
					location.href = "/zxtms/index.php/Admin/Leave/View";
				} else {
					layer.msg(data.msg, {
						icon : 5
					});
				}
			},
			error : function() {
				layer.msg('服务异常！');
			}
		});

	}

}


function pltotal(){
	var xzall=document.getElementById('xzall');
	var cq = $(".wsj");
//	var wsj = "";
	var checkedList = new Array(); 	
	for (var i = 0; i < cq.length; i++) {		
		if (cq.eq(i).prop("checked")) {
			checkedList[i]=cq.eq(i).val();			
		}
		
	}
 
	if(xzall.checked==false){
		layer.msg('你还没有选择合计人员！', {
			icon : 5
		});
	}else{
	layer.confirm('您确定要批量合计该月份的所有人员吗？', {
		btn : [ '确定', '取消' ]
	}, function() {
		$.ajax({
			url : "/zxtms/index.php/Admin/Kqbf/pltotal",
			type : "post",
			data : {
				'checkedList' : checkedList,				
			},
			dataType : "json",
			beforeSend : function() {
				layer.msg('正在批量合计....', {
					icon : 16,
					time : 1000000,
					shade : 0.01
				
				});
			},
			success : function(data) {
				if (data.state == 1) {
					location.href = location.href;
					layer.msg(data.msg, {
						icon : 6
					});
				} else {
					layer.msg(data.msg, {
						icon : 5
					});
				}
			},
			error : function() {
				layer.msg('服务异常！');
			}

		});

	});
	
 }
}



function tdelete(){
	
	var xzall=document.getElementById('xzall');
	var cq = $(".wsj");
	var wsj = "";
	for (var i = 0; i < cq.length; i++) {
		if (cq.eq(i).prop("checked")) {
			wsj += cq.eq(i).val() + ',';
		}
	}	
	if(xzall.checked==false){
		layer.msg('你还没有选择人员！', {
			icon : 5
		});
	}else{
	layer.confirm('您确定要删除该月份的所有数据吗？', {
		btn : [ '确定', '取消' ]
	}, function() {
		$.ajax({
			url : "/zxtms/index.php/Admin/Kqbf/tdelete",
			type : "post",
			data : {
				'wsj' : wsj				
			},
			dataType : "json",
			beforeSend : function() {
				layer.msg('正在删除....', {
					icon : 16,
					time : 1000000,
					shade : 0.01
				
				});
			},
			success : function(data) {
				if (data.state == 1) {
					location.href = location.href;
					layer.msg(data.msg, {
						icon : 6
					});
				} else {
					layer.msg(data.msg, {
						icon : 5
					});
				}
			},
			error : function() {
				layer.msg('服务异常！');
			}

		});

	});
	
 }
}

function ygdr(){
	var monthid=document.getElementById('monthid').value;
	var cq = $(".cq");
	var plstr = "";
	for (var i = 0; i < cq.length; i++) {
		if (cq.eq(i).attr("checked")) {
			plstr += cq.eq(i).val() + ',';
		}
	}
	layer.confirm('您确定要导入该月份的所有员工吗？', {
		btn : [ '确定', '取消' ]
	}, function() {
		$.ajax({
			url : "/zxtms/index.php/Admin/Kqbf/ygdr",
			type : "post",
			data : {
				'plstr' : plstr,
				'monthid':monthid
			},
			dataType : "json",
			beforeSend : function() {
				layer.msg('正在导入....', {
					icon : 16,
					time : 1000000,
					shade : 0.01
				
				});
			},
			success : function(data) {
				if (data.state == 1) {
					location.href = location.href;
					layer.msg(data.msg, {
						icon : 6
					});
				} else {
					layer.msg(data.msg, {
						icon : 5
					});
				}
			},
			error : function() {
				layer.msg('服务异常！');
			}

		});

	});
}

function model(uid){		
	$.ajax({
		url: "/zxtms/index.php/Admin/Kqbf/edit",
		type: "get",
		data:{"uid":uid},
		dataType: "json",	
		/*beforeSend : function() {
			layer.load(1);
		},*/
		success : function(data) {
			if (data.state == 1) {				
			/*    layer.closeAll('loading');	*/				
				$('#hiddentip').show();
				document.getElementById('taskdate').value=data.taskdate;
				document.getElementById('taskadd').value=data.taskadd;
				document.getElementById('taskleave').value=data.taskleave;
				document.getElementById('tasklate').value=data.tasklate;
				document.getElementById('etid').value=data.id;
				document.getElementById('editname').innerHTML=data.staff_name;
				
			} else {
				layer.msg(data.msg, {
					icon : 5
				});
			}
		},
		error : function() {
			layer.msg('服务异常！');
		}
		});
	
}
function amclose(){
	$('#hiddentip').hide();
}

function editsure(){
 var taskdate=document.getElementById('taskdate').value;
 var taskadd=document.getElementById('taskadd').value;
 var taskleave=document.getElementById('taskleave').value;
 var tasklate=document.getElementById('tasklate').value;
 var etid=document.getElementById('etid').value;
 $.ajax({
		url : "/zxtms/index.php/Admin/Kqbf/editsure",
		type : "post",
		data : {
			'taskdate' : taskdate,
			'taskadd' : taskadd,
			'taskleave' : taskleave,
			'tasklate' : tasklate,
		    'etid' :  etid
		},
		dataType : "json",
		beforeSend : function() {
			layer.msg('正在修改....', {
				icon : 16,			
				shade : 0.01
			
			});
		},
		success : function(data) {
			if (data.state == 1) {
				location.href = location.href;
				layer.msg(data.msg, {
					icon : 6
				});
			} else {
				layer.msg(data.msg, {
					icon : 5
				});
			}
		},
		error : function() {
			layer.msg('服务异常！');
		}

	});
}


























